package com.vhall.component.entity.room.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * RoomStatusEnum-
 *
 * @author xing.wang
 * @date 2022/9/27
 */
@Getter
public enum RoomStatusEnum {
    TO_BE_BROADCAST(0, "待直播"),
    LIVE_BROADCAST(1, "直播中"),
    END_BROADCAST(2, "已结束");
    private Integer status;

    private String describe;

    RoomStatusEnum(Integer status, String name) {
        this.status = status;
        this.describe = name;
    }

    private static Map<Integer, String> kv = new HashMap<>(8);

    static {
        for (RoomStatusEnum value : values()) {
            kv.put(value.status, value.describe);
        }
    }

    /**
     * 通过状态获取到类型描述
     *
     * @param status 状态
     * @return 描述
     */
    public static String getDescribe(Integer status) {
        return kv.getOrDefault(status, "");
    }


    public static RoomStatusEnum parse(Integer value) {
        for (RoomStatusEnum statusEnum : RoomStatusEnum.values()) {
            if (statusEnum.getStatus().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }
}
